<template>
	<view style="padding: 30rpx;">
		<view class="page-box" style="">
			<view class="order" v-for="(res, index) in orderList" :key="res.id" style="margin-bottom: 20rpx;padding: 20rpx;background-color: #fff;border-radius: 16rpx;">
				<view @click="toDetail(res.id)">
					<view style="display: flex;align-items: center;justify-content: space-between;">
						<view style="font-size: 32rpx;">联单号：{{res.tranOrderCode}}</view>
						<view v-if="res.jointOrderStatus==sysConstant.PRE_ORDER_STATUS" style="color: red;">待转运</view>
						<view v-if="res.jointOrderStatus==sysConstant.ING_ORDER_STATUS" style="color: #ff9900;">转运中
						</view>
						<view v-if="res.jointOrderStatus==sysConstant.END_ORDER_STATUS" style="color: green;">已完成</view>
						<view v-if="res.jointOrderStatus==sysConstant.CANCEL_ORDER_STATUS" style="color: #999;">已取消
						</view>
					</view>
					<view style="margin-top: 20rpx;color: #999;" v-if="type==0">
						{{res.soilFieldName}}
					</view>
					<view style="margin-top: 20rpx;color: #999;" v-if="type==1">
						{{res.soilSiteCompanyName}}
					</view>
					<view style="color: #999;margin: 20rpx 0;" v-if="type==0">
						运输量：{{res.removalQuantity}} 吨
					</view>
					<view style="color: #999;margin: 20rpx 0;" v-if="type==1">
						接收量：{{res.receivingQuantity}} 吨
					</view>
					<view style="color: #999;">
						转运时间：{{res.startTime}}
					</view>
					<view style="color: #999;margin-top: 20rpx;">
						完成时间：2023-12-15 14:30
					</view>
				</view>
			</view>
			<view style="margin-top: 30rpx;">
				<!-- <u-loadmore :status="loadStatus[0]" bgColor="#f8f8f8"></u-loadmore> -->
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				constructionSiteId: '', //施工工地(外键)id
				soilSiteCompanyId: '',
				type: '0',
				pageSize: 200,
				pageNum: 1,
				orderList: []
			}
		},
		onLoad(opt) {
			this.orderList = []
			let sitesId = opt.sitesId
			let type = opt.type
			console.log(type)
			this.type = type
			if (type == 0) {
				this.constructionSiteId = sitesId
			} else {
				this.soilSiteCompanyId = sitesId
			}
			this.initDataList()
		},
		methods: {
			initDataList() {
				uni.$u.get(`/driver/wasteTransportationOrderPage?pageNum=${this.pageNum}&pageSize=${this.pageSize}
				&soilSiteCompanyId=${this.soilSiteCompanyId}
				&constructionSiteId=${this.constructionSiteId}`, {
					jointOrderStatus: this.sysConstant.END_ORDER_STATUS
				}).then(res => {
					if (res.code == 200) {
						this.orderList = res.rows
					}
				})
			},
			toDetail(orderId) {
				console.log(orderId)
				uni.navigateTo({
					url: "/pages/order/detail/detail?id=" + orderId
				})
			},
		}
	}
</script>

<style>

</style>